/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PatientInsurancePanel.java
 *
 * Created on Aug 14, 2011, 10:46:52 PM
 */
package panels;

import conn.EMIS4Connection;
import dao.InsuranceDao;
import dao.ProviderDao;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import obj.Insurance;
import obj.Provider;
import util.PersonRequested;

/**
 *
 * @author NATHAN
 */
public class PatientInsurancePanel extends javax.swing.JPanel {
  
  private EMIS4Connection conn = EMIS4Connection.getInstance();
  private PersonRequested pr = PersonRequested.getInstance();
  private Insurance insurance;
  private InsuranceDao insuranceDAO;
  private Provider provider;
  private ProviderDao providerDAO;
  private List<Provider> providerList;

  /** Creates new form PatientInsurancePanel */
  public PatientInsurancePanel() {
    
    insurance = new Insurance();
    insuranceDAO = new InsuranceDao();
    provider = new Provider();
    providerDAO = new ProviderDao();
    
    initComponents();
    
    fillInformation();
  }
  
  private void fillInformation() {
    try {
      conn.connect();
      providerList = providerDAO.loadAll(conn.getConnection());
      
      for (Provider item : providerList) {
        providerComboBox.addItem(item.getName());
      }
    } catch (SQLException ex) {
      Logger.getLogger(PatientInsurancePanel.class.getName()).log(Level.SEVERE, null, ex);
    }
    
  }

  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    providerComboBox = new javax.swing.JComboBox();
    jLabel3 = new javax.swing.JLabel();
    policyNumberTextField = new javax.swing.JTextField();
    jLabel4 = new javax.swing.JLabel();
    copayTextField = new javax.swing.JFormattedTextField();
    activeCheckBox = new javax.swing.JCheckBox();
    submitButton = new javax.swing.JButton();

    setBackground(new java.awt.Color(220, 220, 210));
    setLayout(new java.awt.GridBagLayout());

    jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
    jLabel1.setText("Insurance Information");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 4;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.insets = new java.awt.Insets(20, 15, 0, 0);
    add(jLabel1, gridBagConstraints);

    jLabel2.setText("Provider:");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.insets = new java.awt.Insets(15, 25, 0, 0);
    add(jLabel2, gridBagConstraints);

    providerComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "NONE" }));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.insets = new java.awt.Insets(10, 5, 0, 0);
    add(providerComboBox, gridBagConstraints);

    jLabel3.setText("Policy Number:");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.insets = new java.awt.Insets(14, 20, 0, 0);
    add(jLabel3, gridBagConstraints);

    policyNumberTextField.setPreferredSize(new java.awt.Dimension(80, 20));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
    gridBagConstraints.insets = new java.awt.Insets(10, 5, 0, 15);
    add(policyNumberTextField, gridBagConstraints);

    jLabel4.setText("Co-Payment:");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.insets = new java.awt.Insets(14, 25, 0, 0);
    add(jLabel4, gridBagConstraints);

    copayTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00"))));
    copayTextField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
    copayTextField.setText("0.00");
    copayTextField.setPreferredSize(new java.awt.Dimension(60, 20));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.insets = new java.awt.Insets(10, 5, 15, 0);
    add(copayTextField, gridBagConstraints);

    activeCheckBox.setText("Active");
    activeCheckBox.setOpaque(false);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.insets = new java.awt.Insets(10, -10, 0, 15);
    add(activeCheckBox, gridBagConstraints);

    submitButton.setText("Submit");
    submitButton.setOpaque(false);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(6, 15, 15, 15);
    add(submitButton, gridBagConstraints);
  }// </editor-fold>//GEN-END:initComponents
  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JCheckBox activeCheckBox;
  private javax.swing.JFormattedTextField copayTextField;
  private javax.swing.JLabel jLabel1;
  private javax.swing.JLabel jLabel2;
  private javax.swing.JLabel jLabel3;
  private javax.swing.JLabel jLabel4;
  private javax.swing.JTextField policyNumberTextField;
  private javax.swing.JComboBox providerComboBox;
  private javax.swing.JButton submitButton;
  // End of variables declaration//GEN-END:variables
}
